package org.NooLab.docserver.properties;

import java.util.ArrayList;

public class ControlSettingsSection {

	public ArrayList<String> attributes = new ArrayList<String>();
	public ArrayList<ArrayList<String>> attrValues = new ArrayList<ArrayList<String>>();
	
	public int priority = -1 ;

	// ------------------------------------------------------------------------
	public ControlSettingsSection(){
		
	}
	// ------------------------------------------------------------------------	

	
	public int getIndexOfAttribute( String label){
		int index = -1;
		String str;
		
		if (attributes!=null){
			for (int i=0;i<attributes.size();i++){
				str = attributes.get(i);
				if (str.contentEquals(label)){
					index=i;
					break;
				}
			}// i->
		
		}
		return index;
	}

	public ArrayList<String> getValuesOfAttribute( String label){
		
		ArrayList<String> attrVals = new ArrayList<String>();
		int p;
		
		p = getIndexOfAttribute( label) ;
		
		for (int i=0;i<attrValues.size();i++){
			if ((p >= 0) && (attrValues != null) && 
				(i <= attrValues.size() - 1) && (p <= attrValues.get(i).size() - 1)) {
				attrVals.add(attrValues.get(i).get(p));
			}
		}
		return attrVals;
	}

	public String getValueOfAttribute( int index, String label){
		String attrVal = "";
		int p;
		
		p = getIndexOfAttribute( label) ;
		
		if ((p>=0) && (attrValues!=null) && (index<attrValues.size()) && (p<attrValues.get(index).size())){
			attrVal = attrValues.get(index).get(p);
		}
		
		return attrVal;
	}

	
	public String getAttributeAtIndex( int index, int attrindex){
		String label ="";
		int p=attrindex;
		
		if ((p>=0) && (attrValues!=null) && (p<=attrValues.size()-1)){
			label = attrValues.get(index).get(p);
		}
		
		return label;
	}
	
	
	
	// ------------------------------------------------------------------------	
	
	public ArrayList<String> getAttributes() {
		return attributes;
	}

	public void setAttributes(ArrayList<String> attributes) {
		this.attributes = attributes;
	}

	public ArrayList<ArrayList<String>> getAttrValues() {
		return attrValues;
	}

	public void setAttrValues(ArrayList<ArrayList<String>> attrValues) {
		this.attrValues = attrValues;
	}

	public int getPriority() {
		return priority;
	}

	public void setPriority(int priority) {
		this.priority = priority;
	}
	
	
	
	
	
	
}
